package pers.bc.utils.test;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.Proxy;

public class ProxyDiagnostics {
    public static void main(String[] args) {
        String proxyHost = "47.94.248.156";
        int proxyPort = 443;
        
        try {
            // 测试代理服务器是否可达
            // 2、企税通接口接入地址 https://qst.imfbp.com (47.94.248.156)  端口443 ；使用HTTPS协议。
            Socket socket = new Socket();
            socket.connect(new InetSocketAddress(proxyHost, proxyPort), 5000);
            System.out.println("代理服务器连接成功");
            socket.close();
            
            // 测试通过代理连接到目标服务器
            Socket proxySocket = new Socket(new Proxy(Proxy.Type.HTTP, 
                    new InetSocketAddress(proxyHost, proxyPort)));
            proxySocket.connect(new InetSocketAddress("47.94.248.156", 443), 10000);
            System.out.println("通过代理连接到目标服务器成功");
            proxySocket.close();
            
        } catch (Exception e) {
            System.err.println("连接测试失败: " + e.getMessage());
            e.printStackTrace();
        }
    }
}